package com.wondertek.poms.service.controller;

import com.wondertek.poms.common.vo.PageBean;
import com.wondertek.poms.common.vo.ResultBean;
import com.wondertek.poms.core.service.IPrdFreeFlowService;
import com.wondertek.poms.dao.po.PrdFreeFlow;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "PrdFreeFlowController", description = "免流量")
@RestController
@RequestMapping(value="/prd-free-flow")
public class PrdFreeFlowController {

    @Autowired
    private IPrdFreeFlowService prdFreeFlowService;

    /** 查询免流量列表
     *@author gaozhengxing gaozhenghang@wondertek.com.cn
     *@date 2020/12/24 14:31
     *@param pomsId 节目id
     *@param pomsType 节目状态
     *@return 免流量 列表*/
    @ApiOperation("免流量 列表")
    @GetMapping(value = "/list")
    @ResponseBody
    public ResultBean list(Long pomsId,Integer pomsType){
        PrdFreeFlow pf=new PrdFreeFlow();
        if(pomsId!=null){
            pf.setPomsId(pomsId);
        }
        if(pomsId!=null){
            pf.setPomsType(pomsType);
        }
        List<PrdFreeFlow> list=prdFreeFlowService.findAll(pf);
        return PageBean.ok(list);
    }

    @ApiOperation("免流量 添加")
    @PostMapping(value = "/add")
    @ResponseBody
    public ResultBean add(@RequestBody PrdFreeFlow prdFreeFlow){
        prdFreeFlowService.save(prdFreeFlow);
        return ResultBean.ok();
    }

    @ApiOperation("免流量 更新")
    @PostMapping(value = "/update")
    @ResponseBody
    public ResultBean update(@RequestBody PrdFreeFlow prdFreeFlow){
        System.out.println(prdFreeFlow);
        prdFreeFlowService.save(prdFreeFlow);
        return ResultBean.ok();
    }

    @ApiOperation("免流量 删除")
    @DeleteMapping(value = "/del")
    @ResponseBody
    public ResultBean del(Long id){
        prdFreeFlowService.deleteById(id);
        return ResultBean.ok();
    }


}
